<template>
	<view class='mainBody'>
		<!-- 出差人员 -->
		<view class='person'>
			<view class="personTop">
				<view class="personName">出差人员</view>
				<image v-if="currentDate.result==1" class='personStatus' src="../../static/index/shenpi.png"></image>
				<image v-if="currentDate.result==2" class='personStatus' src="../../static/index/yibohui.png"></image>
				<image v-if="currentDate.result==3" class='personStatus' src="../../static/index/yitongguo.png"></image>
				<image v-if="currentDate.result==4" class='personStatus' src="../../static/index/yichehui.png"></image>
				<image v-if="currentDate.result==5" class='personStatus' src="../../static/index/yiquxiao.png"></image>
			</view>
			<view class="personBottom">
				<view class="nameItem" v-for="(item,index) in names" :key="index">{{item}}</view>
			</view>
		</view>
		<!-- 出差行程 -->
		<view class='journey'>
			<view class="title">出差行程</view>
			<view class="journeyMessage">
				<view class="leftItem">
					出差方式
				</view>
				<view class="rightItem">
					火车
				</view>
			</view>
			<view class="journeyMessage">
				<view class="leftItem">
					出差时间
				</view>
				<view class="rightItem">
					{{currentDate.startTime}} 至 {{currentDate.endTIme}}
				</view>
			</view>
			<view class="journeyMessage">
				<view class="leftItem">
					出发城市
				</view>
				<view class="rightItem">
					{{currentDate.from}}
				</view>
			</view>
			<view class="journeyMessage">
				<view class="leftItem">
					到达城市
				</view>
				<view class="rightItem">
					{{currentDate.arrive}}
				</view>
			</view>
			<view class="journeyMessage">
				<view class="leftItem">
					出差类型
				</view>
				<view class="rightItem">
					{{currentDate.businessType}}
				</view>
			</view>
		</view>
		<!-- 审批流程 -->
		<view class='approve' v-if="flag!=='reimburse'">
			<view class="title">审批流程</view>
			<!-- 本人提交 -->
			<view class="processMes">
				<view class="porcessItem">
					<view class="itemLeft">
						<image class="typeImg" src="../../static/index/tijiao.png" mode=""></image>
						<view class="messView">
							<view class="nameItem">安家汇 (产品经理)</view>
							<view class="proItem">提交申请</view>
						</view>
					</view>
					<view class="itemRight">2022-04-03 10:22:33</view>
				</view>
			</view>
			<!-- 其它人审批 -->
			<view class="processMes" v-for="(item,index) in approver" :key='index'>
				<view class="porcessItem">
					<view class="itemLeft">
						<image v-if="item.result=='审批通过'" class="typeImg" src="../../static/index/shenpitongguo.png"
							mode=""></image>
						<image v-if="item.result=='审批驳回'||item.result=='取消申请'" class="typeImg"
							src="../../static/index/bohui.png" mode=""></image>
						<image v-if="item.result=='待审批'" class="typeImg" src="../../static/index/shenpizhong.png"
							mode=""></image>
						<view class="leftLine"></view>
						<view class="messView">
							<view class="nameItem">{{item.name}}</view>
							<view class="proItem">{{item.result}}</view>
							<view v-if="item.result=='取消申请'" class='cancelReason'>取消原因，我不想去了</view>
							<view v-if="item.result=='取消申请'" class="cancelLine"></view>
						</view>
					</view>
					<view class="itemRight">{{item.time}}</view>
				</view>
			</view>
		</view>
		<!-- 审批中 -->
		<view class="bottomBtn" v-if="currentDate.result==1">
			<view class="cancelBtn" @click="recall">撤回</view>
		</view>
		<!-- 已驳回 、已撤回-->
		<view class="bottomBtn" v-if="currentDate.result==2||currentDate.result==4">
			<view class="cancelBtn" @click="edit">修改</view>
		</view>
		<!-- 通过 -->
		<view class="bottomBtn" v-if="currentDate.result==3">
			<view class="cancelBtn" @click="cancel">取消申请</view>
		</view>
		<!-- 取消原因弹窗 -->
		<view>
			<uni-popup ref="popup" background-color="#fff">
				<view class="popup-content" >
					<view class="popTop">
						<view class="closePop" @click="closePop">X</view>
						<view class="cancelReasons">取消原因</view>
					</view>
					<view class="isTextArea">
						<uni-easyinput type="textarea" v-model="cancelReason" placeholder="请输入您的取消原因,谢谢!"></uni-easyinput>
					</view>
					<view class="bottomSubmit" @click="cancelCommit">提交</view>
				</view>
			</uni-popup>
		</view>
		<view>
			<uni-popup ref="alertDialog" type="dialog">
				<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确定" title="温馨提示" content="您确定要撤回申请吗？" @confirm="dialogConfirm"
					@close="dialogClose"></uni-popup-dialog>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad(option) {
			this.flag = option.flag
			this.currentDate = JSON.parse(decodeURIComponent(option.item));
			if (this.currentDate && this.currentDate.personel) {
				this.names = this.currentDate.personel.split('、')
			}
		},
		data() {
			return {
				// flag页面跳转的时候需要将flag值传过来，报销申请页面不需要流程，出差申请需要显示详情
				flag:'reimburse',
				cancelReason:'',//取消原因
				currentDate: {},
				names: [],
				approver: [{ //审批人列表
						name: '王家和 (主管)',
						time: '2022-04-03 10:22:33',
						result: '审批通过',
					}, {
						name: '成鑫 (部门经理)',
						time: '2022-04-03 10:22:33',
						result: '审批通过',
					}, {
						name: '安家汇 (产品经理)',
						time: '2022-04-03 10:22:33',
						result: '取消申请',
					}, {
						name: '成鑫 (部门经理)',
						time: '2022-04-03 10:22:33',
						result: '审批通过',
					}, {
						name: '安家汇 (产品经理)',
						time: '2022-04-03 10:22:33',
						result: '取消申请',
					}, {
						name: '成鑫 (部门经理)',
						time: '2022-04-03 10:22:33',
						result: '审批通过',
				}]
			}
		},
		methods: {
			// open:function(){
			// 	this.$refs.popop[0].open()
			// },
			//撤回
			recall() {
				this.$refs.alertDialog.open()
				console.log('撤回申请');
			},
			//修改
			edit() {
				console.log('修改');
			},
			//取消申请
			cancel() {
				// this.$refs.popup.
				console.log(this.$refs.popup);
				this.$refs.popup.open('bottom')
				console.log('取消申请');
			},
			//关闭弹窗
			closePop(){
				this.$refs.popup.close()
			},
			//提交取消原因
			cancelCommit(){
				console.log(this.cancelReason);
				this.$refs.popup.close()
				this.cancelReason=''
			},
			//
			dialogClose(){},
			//
			dialogConfirm(){}
			
			
		}
	}
</script>

<style lang="scss" scoped>
	.mainBody {
		box-sizing: border-box;
		background: #f7f7f7;
		min-height: 100vh;
		border-top: 1rpx solid transparent;
	}

	.title {
		box-sizing: border-box;
		padding: 20rpx 31rpx;
		height: 92rpx;
		font-size: 34rpx;
		color: #333;
		font-weight: 500;
		border-bottom: 1rpx solid #e5e5e5;
	}

	.person {
		box-sizing: border-box;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		background: #fff;

		.personTop {
			display: flex;
			height: 92rpx;
			padding: 0 31rpx;
			justify-content: space-between;
			align-items: center;
			border-bottom: 1rpx solid #e5e5e5;

			.personName {
				font-size: 34rpx;
				color: #333;
				font-weight: 500;
			}

			.personStatus {
				width: 94rpx;
				height: 40rpx;
			}
		}

		.personBottom {
			display: flex;
			flex-wrap: wrap;
			padding: 30rpx 32rpx 8rpx 32rpx;

			.nameItem {
				box-sizing: border-box;
				padding: 0 30rpx;
				width: 213rpx;
				height: 64rpx;
				line-height: 64rpx;
				margin-right: 24rpx;
				margin-bottom: 24rpx;
				border-radius: 32rpx;
				border: 1rpx solid #e5e5e5;
				font-size: 32rpx;
				color: #333;
				text-align: center;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

			.nameItem:nth-of-type(3n) {
				margin-right: 0;
			}
		}
	}

	.journey {
		background: #fff;
		margin-bottom: 20rpx;

		.journeyMessage {
			display: flex;
			justify-content: space-between;
			padding: 10rpx 32rpx;
			height: 60rpx;
			line-height: 60rpx;
			font-size: 32rpx;

			.leftItem {
				color: #666;
			}

			.rightItem {
				color: #333;
			}
		}
	}

	.approve {
		background: #fff;
		padding-bottom: 50rpx;

		.processMes {
			padding: 29rpx 32rpx 30rpx 32rpx;

			.porcessItem {
				display: flex;
				justify-content: space-between;

				.itemLeft {
					display: flex;

					.typeImg {
						position: relative;
						top: 8rpx;
						left: 0;
						height: 30rpx;
						width: 30rpx;
						margin-right: 8rpx;
					}

					.leftLine {
						position: relative;
						top: -80rpx;
						left: -24rpx;
						height: 73rpx;
						border-left: 1rpx solid #e5e5e5;
					}

					.messView {
						position: relative;

						.nameItem {
							height: 45rpx;
							line-height: 45rpx;
							font-size: 32rpx;
							color: #333;
						}

						.proItem {
							font-size: 26rpx;
							color: #666;
						}

						.cancelReason {
							margin-top: 16rpx;
							color: #ed3944;
							font-size: 26rpx;
						}

						.cancelLine {
							position: absolute;
							top: 50rpx;
							left: -26rpx;
							height: 73rpx;
							border-left: 1rpx solid #e5e5e5;
						}
					}
				}

				.itemRight {
					padding-top: 8rpx;
					font-size: 26rpx;
					color: #666;
				}
			}
		}
	}

	.bottomBtn {
		width: 750rpx;
		margin-top: 33rpx;
		padding-bottom: 50rpx;
		background: #fff;

		.cancelBtn {
			height: 88rpx;
			background: #ffa900;
			line-height: 88rpx;
			text-align: center;
			color: #fff;
			font-size: 36rpx;
		}
	}
	.popup-content {
			padding-bottom: 68rpx;
			height: 571rpx;
			background-color: #fff;
		}
	.popTop{
		position: relative;
		height: 100rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		padding:0 30rpx;
		border-bottom: 1rpx solid #e5e5e5;
		.closePop{
			position: absolute;
			top: 50%;
			left:30rpx;
			transform: translateY(-50%);
			color: #999;
			font-size: 32rpx;
		}
		.cancelReasons{
			font-size: 36rpx;
			color: #333;
		}
	}
	.isTextArea{
		padding: 30rpx 32rpx 0;
		margin-bottom: 72rpx;
		::v-deep.input-padding{
			height: 280rpx;
			color: #c4c4c4;
			padding-left: 0;
			margin: 0;
			padding: 32rpx 16rpx;
			background: #f2f2f2;
		}
	}
	.bottomSubmit{
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 36rpx;
		height: 88rpx;
		margin: 0 32rpx;
		background: #ffa900;
		color: #fff;
	}
	::v-deep .uni-button-color{
		color: #ffa900;
	}
	
</style>
